/* GUI CONVERTED from rcslrb.p (converter v1.76) Thu Dec 20 07:32:08 2001 */
/* rcslrb.p - Stage List Rollback                                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.12.1.5 $                                                      */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.4      LAST MODIFIED: 11/18/94   BY: GWM *H604*                */
/* REVISION: 7.5      LAST MODIFIED: 07/19/95   BY: GWM *J049*                */
/* REVISION: 8.5      LAST MODIFIED: 07/25/96   BY: jpm *J11D*                */
/* REVISION: 8.6      LAST MODIFIED: 10/03/96   BY: *K003* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 12/16/96   BY: *K03J* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 01/28/97   BY: *K059* Kieu Nguyen        */
/* REVISION: 8.6      LAST MODIFIED: 04/02/97   BY: *K09H* Vinay Nayak-Sujir  */
/* REVISION: 8.5      LAST MODIFIED: 04/07/97   BY: *J1M3* Jean Miller        */
/* REVISION: 8.6      LAST MODIFIED: 05/13/97   BY: *J1MP* Aruna Patil        */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 04/21/98   BY: *J2JY* Niranjan R.        */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 08/27/98   BY: *K1WQ* Irine D'mello      */
/* REVISION: 8.6E     LAST MODIFIED: 06/22/99   BY: *K21B* Reetu Kapoor       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 09/06/00   BY: *N0RG* Mudit Mehta        */
/* $Revision: 1.12.1.5 $  BY: Jean Miller        DATE: 12/14/01  ECO: *P03Q*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i}

define new shared variable ship like abs_id label "Shipper ID".
define new shared variable ship1 like abs_id.
define new shared variable shipfrom like abs_shipfrom.
define new shared variable shipfrom1 like abs_shipfrom.
define variable shipto like abs_shipto no-undo.
define variable shipto1 like abs_shipto no-undo.

define variable ship_from like abs_shipfrom.
define variable roll_back as character format "x(40)".
define variable errorst as logical no-undo.
define variable errornum as integer no-undo.
define variable can_discard as logical no-undo.

define buffer abs_line for abs_mstr.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
shipfrom         colon 15 label "Ship-From"
   shipfrom1        colon 49 label "To" skip
   ship             colon 15 label "Shipper"
   ship1            colon 49 label "To"  deblank
   shipto       colon 15 label "Ship-To"
   shipto1      colon 49 label "To" skip
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

global_site = "".

repeat:

   if ship1 = hi_char then ship1 = "".
   if shipfrom1 = hi_char then shipfrom1 = "".
   if shipto1 = hi_char then shipto1 = "".

   update
      shipfrom shipfrom1
      ship ship1
      shipto shipto1
   with frame a.

   bcdparm = "".
   {mfquoter.i shipfrom}
   {mfquoter.i shipfrom1}
   {mfquoter.i ship }
   {mfquoter.i ship1}
   {mfquoter.i shipto }
   {mfquoter.i shipto1}

   if shipfrom1 = "" then shipfrom1 = hi_char.
   if ship1 = "" then ship1 = hi_char.
   if shipto1 = "" then shipto1 = hi_char.

   if not batchrun then do:
      {gprun.i ""gpsirvr.p""
         "(input shipfrom, input shipfrom1, output return_int)"}
      if return_int = 0 then do:
         next-prompt shipfrom with frame a.
         undo, retry.
      end.
   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "yes"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {mfphead2.i}

   for each abs_mstr where abs_shipfrom >= shipfrom
         and abs_shipfrom <= shipfrom1
         and abs_type = "S"
         and abs_shipto >= shipto
         and abs_shipto <= shipto1
         and abs_id >= "S" + ship
         and abs_id <= "S" + ship1:

      FORM /*GUI*/ 
         abs_id
         roll_back format "x(40)"
      with STREAM-IO /*GUI*/  frame b centered no-labels width 80.

      display
         substring(abs_mstr.abs_id,2) @ abs_id
      with frame b STREAM-IO /*GUI*/ .

      if substring(abs_status,2,1) <> "" then do:
         display
            getTermLabel("ALREADY_CONFIRMED",40) @ roll_back
         with frame b STREAM-IO /*GUI*/ .
         next.  /*Already Confirmed */
      end.

      if abs_nr_id <> "" then do:

         run chk_delnbr
            (input abs_nr_id,
             output can_discard,
             output errorst,
             output errornum).

         if errorst then do:
            {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3}
            next.
         end.

         if not can_discard then do:
            /* Gaps in sequence not permitted */
            {pxmsg.i &MSGNUM=5947 &ERRORLEVEL=1 &MSGBUFFER=roll_back}
            display roll_back with frame b STREAM-IO /*GUI*/ .
            next.
         end.

      end. /* if abs_nr_id <> ""  */

      if abs_preship_id = "" then do:
         display
            getTermLabel("NOT_STAGED",40) @ roll_back
         with frame b STREAM-IO /*GUI*/ .
         next.  /* Not staged */
      end.

      display
         getTermLabel("WAS_ROLLED_BACK_TO",21) + " " +
         substring(abs_preship_id,2) @ roll_back
      with frame b STREAM-IO /*GUI*/ .

      /* Any custom information for printing documents needs
         to have the keys change since abs_id is changing   */
      {gprun.i ""sofsre.p"" "(input recid(abs_mstr),
           input abs_preship_id)"}

      /* ASSIGN PRE-SHIPPER NUMBER TO CARRIER REF IF CARRIER REF IS */
      /* SHIPPER NUMBER */
      {gprun.i ""icshunc.p"" "(input recid(abs_mstr))"}

   end.

   {mfrtrail.i}

end.

/* Internal procedures for accessing NR attributes */
{gpnrseq.i}
